import requests

kw = input("请输入要查找的关键词:")

params = {
    'wd':kw
}
headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36",
}

response = requests.get('http://www.baidu.com/s?',params=params,headers=headers)
with open('baidu.html','w',encoding='utf-8') as fp:
    fp.write(response.content.decode('utf-8'))

print(response.url)